<?php

use Faker\Factory as Faker;
use App\Models\ItemOrderRead;
use App\Repositories\ItemOrderReadRepository;

trait MakeItemOrderReadTrait
{
    /**
     * Create fake instance of ItemOrderRead and save it in database
     *
     * @param array $itemOrderReadFields
     * @return ItemOrderRead
     */
    public function makeItemOrderRead($itemOrderReadFields = [])
    {
        /** @var ItemOrderReadRepository $itemOrderReadRepo */
        $itemOrderReadRepo = App::make(ItemOrderReadRepository::class);
        $theme = $this->fakeItemOrderReadData($itemOrderReadFields);
        return $itemOrderReadRepo->create($theme);
    }

    /**
     * Get fake instance of ItemOrderRead
     *
     * @param array $itemOrderReadFields
     * @return ItemOrderRead
     */
    public function fakeItemOrderRead($itemOrderReadFields = [])
    {
        return new ItemOrderRead($this->fakeItemOrderReadData($itemOrderReadFields));
    }

    /**
     * Get fake data of ItemOrderRead
     *
     * @param array $postFields
     * @return array
     */
    public function fakeItemOrderReadData($itemOrderReadFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'item_id' => $fake->randomDigitNotNull,
            'item_order_id' => $fake->randomDigitNotNull,
            'wechat_user_id' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $itemOrderReadFields);
    }
}
